package com.nbsaas.boot.app.rest.convert;

import com.nbsaas.boot.app.api.domain.request.AppRoleRequest;
import com.nbsaas.boot.app.data.entity.App;
import com.nbsaas.boot.app.data.entity.AppRole;
import com.nbsaas.boot.rest.api.Converter;
import com.nbsaas.boot.utils.BeanDataUtils;

/**
 * 角色请求对象转换成实体对象
 */

public class AppRoleEntityConvert implements Converter<AppRole, AppRoleRequest> {

    @Override
    public AppRole convert(AppRoleRequest source) {
        AppRole result = new AppRole();
        BeanDataUtils.copyProperties(source, result);
        if (source.getApp() != null) {
            App app = new App();
            app.setId(source.getApp());
            result.setApp(app);
        }
        return result;
    }
}

